/*
 * marg.h
 *
 * Created: 9/7/2011 1:06:52 PM
 *  Author: GrubyGrub
 */ 


#ifndef MARG_H_
#define MARG_H_

#include <asf.h>

enum SENSORTYPE {
	ACCELEROMETER,
	GYROSCOPE,
	MAGNETOMETER,
	ITG3200
};

typedef struct marg_sensors_t
{
	/*indicates which sensor are we currently referring to*/
	enum SENSORTYPE sensor_t;
	twi_package_t Gyro_pkt, Acc_pkt, Mag_pkt, Gyro_pkt_r, Acc_pkt_r, Mag_pkt_r;
	char Gyro_buf[6], Acc_buf[6], Mag_buf[6];
	
	/*All MARG XYZ values*/
	signed short A_x, A_y, A_z, M_x, M_y, M_z, G_x, G_y, G_z;
	
	/*If MARG sensors have been updated*/
	bool A_Set, M_Set, G_Set;
	
	/*if we are in the process of updating these OR using*/
	bool A_Lock, M_Lock, G_Lock;
	
	unsigned long previousUpdate;
	/*MARG sensor update frequency in HZ*/
	//bool A_Freq, M_Freq, G_Freq;
	
	/*decreciated*/
	float Gs_x, Gs_y, Gs_z;
	
	float p,r,y;
	float kp,ki,kd;
	
	
	/*EKF state vars*/
	 float state_q0;
	 float state_q1;
	 float state_q2;
	 float state_q3;
	 float state_gb0;
	 float state_gb1;
	 float state_gb2;
	
}marg_sensors_t;



#endif /* MARG_H_ */